import items from './items.js';
const datas = [
	{ name: '张飞', sex: '男', age: 18, key: 0 }
];

export default function({ Button, $JiessTable }) {
	let key = 1;
	let tableMidder = null;
	this.add(
		this.render({
			is: Button,
			onClick: () => {
				const { datas } = tableMidder.proxy;
				const newLine = { name: `貂蝉${key++}`, sex: '女', age: 16, key };
				tableMidder.proxy.datas = [...datas, newLine];
			}
		}, '添加行'),
		this.render({
			items,
			// 初始数据
			datas,
			is: $JiessTable,
			create: midder => tableMidder = midder,
			render(midder, { table }) {
				this.add(table)
			}
		})
	)
}